package com.rsk.service.impl;


import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;
import com.rsk.dao.SysAuthorityRepository;
import com.rsk.entity.SysAuthority;
import com.rsk.service.SysAuthorityService;
import com.rsk.utils.algorithm.SnowflakeIdWorker;


@Service(interfaceClass = SysAuthorityService.class)
public class SysAuthorityServiceImpl implements SysAuthorityService{
	
	@Autowired
	private SysAuthorityRepository sysAuthorityRepository;

	@Transactional
	public int saveSysAuthority(String authName, String authCode, Long menuId,
			Long operatorUser) {
		SysAuthority sysAuthority = new SysAuthority();
		sysAuthority.setId(SnowflakeIdWorker.generateId(true));
		sysAuthority.setAuthName(authName);
		sysAuthority.setAuthCode(authCode);
		sysAuthority.setOperatorUser(operatorUser);
		sysAuthority.setOperatorTime(new Date());
		sysAuthorityRepository.saveAndFlush(sysAuthority);
		return 1;
	}
	
	@Transactional
	public int updateSysAuthority(Long id, String authName, String authCode,
			Long operatorUser) {
		return sysAuthorityRepository.updateSysAuthority(id, authName, authCode, operatorUser);
	}

	@Transactional
	public int delSysAuthority(Long id, Long operatorUser) {
		return sysAuthorityRepository.delSysAuthority(id, operatorUser);
	}

}
